#include "MiniHandler.h"

MiniHandler::MiniHandler(MiniObject *obj)
    : m_object(obj), m_vertex(nullptr), m_basisColor({1, 1, 1})
{
}

MiniHandler::~MiniHandler()
{
    if (m_object != nullptr)
        delete m_object;
    for (auto item : m_vertices)
        delete [] item;
    for (auto item : m_indices)
        delete [] item;
}

int MiniHandler::GetObjNum() const
{
    return m_vertices.size();
}

float *MiniHandler::GetVertices(int i) const
{
    return m_vertices[i];
}

unsigned int *MiniHandler::GetIndices(int i) const
{
    return m_indices[i];
}

int MiniHandler::GetVerticesCount(int i) const
{
    return m_countVertices[i];
}

int MiniHandler::GetIndicesCount(int i) const
{
    return m_countIndices[i];
}

int MiniHandler::GetMode(int i) const
{
    return m_modes[i];
}

int MiniHandler::GetLineWidth(int i) const
{
    return m_lineWidth[i];
}

QVector3D MiniHandler::GetColor(int i) const
{
    return m_color[i];
}

QVector3D MiniHandler::GetBasisColor() const
{
    return m_basisColor;
}

void MiniHandler::SetColor(QVector3D color)
{
    m_color[0] = color;
}

void MiniHandler::SetBasisColor(QVector3D color)
{
    m_basisColor = color;
}

void MiniHandler::InitHandler()
{
    // 清空所有数组
    for (auto item : m_vertices)
        delete [] item;
    for (auto item : m_indices)
        delete [] item;
    m_vertices.clear();
    m_indices.clear();
    m_countIndices.clear();
    m_countVertices.clear();
    m_modes.clear();
    m_color.clear();
    m_lineWidth.clear();
}
